//
//  ReadViewController.m
//  baodongPro
//
//  Created by feng on 16/3/1.
//  Copyright © 2016年 proper. All rights reserved.
//
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

#import "ReadViewController.h"

@interface ReadViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation ReadViewController
{
    UITableView* readTableView;
    NSMutableArray* _listDiaryArray;

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.containedView.backgroundColor=[UIColor brownColor];
    
    _listDiaryArray=[NSMutableArray array];
    
    readTableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, CGRectGetHeight(self.containedView.frame)-50) style:UITableViewStyleGrouped];
    
    readTableView.delegate=self;
    readTableView.dataSource=self;
    readTableView.rowHeight=100;
    [self.containedView addSubview:readTableView];
    [readTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cells"];
    [_listDiaryArray addObjectsFromArray:@[@"0",@"1",@"2",@"3",@"4",@"0",@"1",@"2",@"3",@"4",@"0",@"1",@"2",@"3",@"4",@"0",@"1",@"2",@"3",@"4",@"0",@"1",@"2",@"3",@"4",@"0",@"1",@"2",@"3",@"4"]];
    
    
    
    
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _listDiaryArray.count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:@"Cells"];
    cell.textLabel.text=@"1234";
    return cell;
}



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row=indexPath.row;
    NSString* tip=[_listDiaryArray objectAtIndex:row];
    [self readCellTitle:tip];

}



-(void)readCellTitle:(NSString*)cellString
{

    AVSpeechSynthesizer *avReader=[[AVSpeechSynthesizer alloc] init];
    AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc]initWithString:cellString]; //需要转换的文本
    [avReader speakUtterance:utterance];


}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
